package com.feicheng.controller.admin;

import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.Akechenglx;
import com.feicheng.persistence.service.IAfxjlService;
import com.feicheng.persistence.service.IAkechenglxService;
import com.feicheng.service.a.FJlService;
import com.feicheng.service.a.FKcService;
import com.feicheng.service.a.FXyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/jl")
public class JlController {

    @Autowired
    FJlService fJlService;
    @Autowired
    FXyService fXyService;
    @Autowired
    IAfxjlService fxjlService;


    @GetMapping("/jltkjl/info")
    public ResultInfo getInfo(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
             String tqjlid){
        JSONObject param = new JSONObject();

        param.put("current", current);
        param.put("size", size);
        param.put("tqjlid", tqjlid);

        param = fXyService.getBmByPage(param);

        return ResultInfo.success(param);
    }


    //教练分页查询
    @GetMapping("/page")
    public ResultInfo getJlsByPage(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
            String searchKey
    ) {
        JSONObject param = new JSONObject();
        param.put("current", current);
        param.put("size", size);
        param.put("jlname", searchKey);
        param = fJlService.getJlsByPage(param);
        return ResultInfo.success(param.get("ajiaolians"));
    }

    //教练详情
    @GetMapping("/info")
    public ResultInfo getJlsInfo(@RequestParam String jlid){
        JSONObject param = new JSONObject();
        param.put("jlid", jlid);
        param = fJlService.getJl(param);
        return ResultInfo.success(param);
    }

    // 分销记录分页
    @GetMapping("/fzjl/page")
    public ResultInfo getFzjlByPage(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
            String searchKey
    ) {
        JSONObject param = new JSONObject();
        param.put("current", current);
        param.put("size", size);
//        param.put("fxclientid", searchKey);
//        fxjlService.param.get("ajiaolians")
        param = fJlService.getFxjlByPage(param);
        return ResultInfo.success(param);
    }

    // 分销记录详情
    @GetMapping("/fxjl/info")
    public ResultInfo getFxjlInfo(@RequestParam String fxjlid){
        JSONObject param = new JSONObject();
        param.put("fxjlid", fxjlid);
        param = fJlService.getFxjlInfo(param);
        return ResultInfo.success(param);
    }

}
